using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using Mussel;
using Mussel.Data;
using Natrue.Data;
using Natrue.Data.FastMapping;
using Natrue.Popedom.Menu;

namespace Natrue.Web.MVC
{
    /// <summary>
    /// MasterPage
    /// </summary>
    public class AuthViewMasterPage : ViewMasterPage, IViewMethods
    {
        private readonly IViewMethods pageBase = ViewMethods.Instanct;

        #region Implementation of IPageBase

        public ILocalAddinItemProxyContainer ProxyContainer
        {
            get { return pageBase.ProxyContainer; }
        }

        public IEnumHelper EnumHelper
        {
            get { return pageBase.EnumHelper; }
        }

        public ISmartView SmartView
        {
            get { return pageBase.SmartView; }
        }

        public ISystemMenu SystemMenu
        {
            get { return pageBase.SystemMenu; }
        }

        public string ApplicationName
        {
            get { return pageBase.ApplicationName; }
        }

        public string BuildSearchConditionControls(Type iboType, string smartListView)
        {
            throw new NotImplementedException();
        }

        public IList<SelectListItem> BuildEnumSelectListItem<T>()
        {
            return pageBase.BuildEnumSelectListItem<T>();
        }

        public IList<SelectListItem> BuildEnumSelectListItem<T>(T selectValue)
        {
            return pageBase.BuildEnumSelectListItem(selectValue);
        }

        public IList<SelectListItem> BuildEnumSelectListItem<T>(string selectValue)
        {
            return pageBase.BuildEnumSelectListItem<T>(selectValue);
        }

        public IList<SelectListItem> BuildEnumSelectListItem(Type enumType)
        {
            return pageBase.BuildEnumSelectListItem(enumType);
        }

        public IList<SelectListItem> BuildEnumSelectListItem(Type enumType, object selectValue)
        {
            return pageBase.BuildEnumSelectListItem(enumType, selectValue);
        }

        public IList<SelectListItem> BuildEnumSelectListItem(Type enumType, string selectValue)
        {
            return pageBase.BuildEnumSelectListItem(enumType, selectValue);
        }

        public IList<SelectListItem> BuildBelongsToSelectListItem<T>(string caption) where T : IBO
        {
            return pageBase.BuildBelongsToSelectListItem<T>(caption);
        }

        public IList<SelectListItem> BuildBelongsToSelectListItem<T>(string caption, T selectValue) where T : IBO
        {
            return pageBase.BuildBelongsToSelectListItem(caption, selectValue);
        }

        public IList<SelectListItem> BuildBelongsToSelectListItem<T>(string caption, Guid selectValue) where T : IBO
        {
            return pageBase.BuildBelongsToSelectListItem<T>(caption, selectValue);
        }

        public IList<SelectListItem> BuildBelongsToSelectListItem(Type belongsToType, string caption)
        {
            return pageBase.BuildBelongsToSelectListItem(belongsToType, caption);
        }

        public IList<SelectListItem> BuildBelongsToSelectListItem(Type belongsToType, string caption, IBO selectValue)
        {
            return pageBase.BuildBelongsToSelectListItem(belongsToType, caption, selectValue);
        }

        public IList<SelectListItem> BuildBelongsToSelectListItem(Type belongsToType, string caption, Guid selectValue)
        {
            return pageBase.BuildBelongsToSelectListItem(belongsToType, caption, selectValue);
        }

        #endregion

        protected User CurrentUser
        {
            get
            {
                HttpCookie cookie = Request.Cookies["currentUserId"];
                if (cookie == null) return null;
                Guid userGuid = new Guid(cookie.Value);
                IPermissionOperation op = ProxyContainer.FindLocalProxy<IPermissionOperation>();
                return op.FindUserdetail(userGuid);
            }
        }
    }
}